﻿using AutoMapper;
using MediatR;
using Traceability.Commont.Domains.ScratchTheFat;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;

namespace U.Enterprise.Api.Applications.SalesWeighings
{
    public class WeighTheFatCreateHandler : IRequestHandler<WeighTheFatCreateCommond, Resqults>
    {
        private readonly IBateRepository<WeighTheFat> _WeighTheFat;

        public WeighTheFatCreateHandler(IBateRepository<WeighTheFat> weighTheFat
            )
        {
            _WeighTheFat = weighTheFat;
        }

        public async Task<Resqults> Handle(WeighTheFatCreateCommond request, CancellationToken cancellationToken)
        {
            var list =new Resqults() { Code=0};

            var query = new WeighTheFat()
            {
                ScaleId= request.ScaleId,
                State= request.State,
                BulkSlaughterNo= request.BulkSlaughterNo,
                AverageWeight= request.AverageWeight,
                MyProperty= request.MyProperty,
                NetWeight= request.NetWeight,
                ProductCode= request.ProductCode,
                Remark= request.Remark,
                RepositoryID= request.RepositoryID,
                Tare =request.Tare,
                WeighTime= request.WeighTime,
                WeightNum = request.WeightNum,
            };



           var gh=await _WeighTheFat.Add(query);

            list.Code = 1;


            return list;


        }
    }
}
